//
//  ButtonCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/16.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "ButtonCell.h"
#import "ButtonCollectionCell.h"

@implementation ButtonCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatView];
    }
    return self;
}
- (void)creatView {
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(50 * WIDTH, 80 * HEIGHT);
    flowLayout.minimumInteritemSpacing = 30;
    flowLayout.sectionInset = UIEdgeInsetsMake(10, 40, 20, 10);
    self.buttonCollect = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0,WIDTH * 375, HEIGHT * 100) collectionViewLayout:flowLayout];
    self.buttonCollect.scrollEnabled = NO;
    [self.buttonCollect registerClass:[ButtonCollectionCell class] forCellWithReuseIdentifier:@"rilegou"];
    self.buttonCollect.delegate = self;
    self.buttonCollect.dataSource = self;
    self.buttonCollect.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.buttonCollect];
    [self.buttonCollect mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.contentView);
    }];
}
- (void)layoutSubviews {
    [super layoutSubviews];
  
    
    
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 4;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ButtonCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"rilegou" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor clearColor];
    if (indexPath.row == 0) {
        [cell.imageView setImage:[UIImage imageNamed:@"iconfont-jingxuan"]];
        cell.label.text = @"精选";
    }else if (indexPath.row == 1) {
        [cell.imageView setImage:[UIImage imageNamed:@"iconfont-iconfonticon"]];
        cell.label.text = @"游玩";
    }else if (indexPath.row == 2) {
         [cell.imageView setImage:[UIImage imageNamed:@"iconfont-meishi"]];
        cell.label.text =  @"美食";
    }else {
            [cell.imageView setImage:[UIImage imageNamed:@"iconfont-zhusu"]];
        cell.label.text = @"住宿";
    }
    
    
   

    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  
    
    [self.delegate give:(indexPath.row)];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
